package com.hskj.controller;

import com.hskj.model.Category;
import com.hskj.model.CategoryQuery;
import com.hskj.model.Product;
import com.hskj.model.ProductQuery;
import com.hskj.service.CategoryService;
import com.hskj.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/product")
public class ProductController {
    @Autowired
    private ProductService service;

    @GetMapping
    public List<Product> select(ProductQuery query){
        List<Product> select = service.select(query);
        return select;
    }

    @PostMapping
    public Integer insert(@RequestBody Product product){
        return service.insert(product);
    }
    @PutMapping
    public Integer update(@RequestBody Product product){
        return service.update(product);
    }
    @DeleteMapping
    public Integer delete(Integer id){
        return service.delete(id);
    }
}
